<center>
<form action="login.php" method="post">
    <table>
        <tr><td><input type="text" name="username"></td></tr>
        <tr><td><input type="password" name="password"></td></tr>
        <tr><td><input type="submit" name="submit" value="submit"></td></tr>
        
    </table>
</form>
</center>
<?php
session_start();
 $_SESSION['uid']="uid";
?>
<?php require_once '../data/user.php';?>
<?php
     echo "<center>";
    if (isset($_POST['submit'])):
?>

<?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    $isOK = FALSE;
    $index = -1;
    for ($i = 0; $i < count($users); $i++) {
    if ((strcmp($users[$i]['username'], $username) == 0) &&
        (strcmp($users[$i]['password'], $password) == 0)) {
         $isOK = TRUE;
         $index = $i;}}
         
    if ( $isOK ) {
      header("Location: http://localhost/votuananh-web1/model/db.php?uid=".$users[$index]['id']);
      
 }  else{    
    echo " <script> alert('dang nhap khong thanh cong')</script>";
 }?>

<?php endif; ?>
